﻿using RAP.Framework.Libary.DomTemplateBuilder.Configuration;
using RAP.Framework.Libary.DomTemplateBuilder.Element.Parameter;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace RAP.Framework.Libary.DomTemplateBuilder
{
	/// <summary>
	/// 模板渲染上下文对象
	/// </summary>
	public class TemplateRenderContext : Hashtable, ITemplateRenderContext
	{
		public IList<Action<object, ITemplateRenderContext>> Callbacks { get; private set; } = new List<Action<object, ITemplateRenderContext>>();

    /// <summary>
    /// 获取当前模板的Attributes
    /// </summary>
    public AttributeCollection CurrentAttributes { get; set; }

    public bool EndTemplate { get; set; }

		public bool IsBreak { get; set; }

		public object CallbackResult { get; set; }

		public ParameterCollection Parameters { get; private set; } = new ParameterCollection();

		public Action<object> DoCallbacks { get; set; }

		public virtual void Dispose( )
		{
			CallbackResult = null;
			Parameters = null;
			Callbacks.Clear();
			Callbacks = null;
		}
	}
}
